/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.language;

import java.util.Locale;
import java.util.ResourceBundle;
import org.jfonia.constants.ModelConstants;

/**
 *
 * @author Rik Bauwens
 */
public class LanguageResource
{
        private static LanguageResource instance;

        private Locale locale;
        private ResourceBundle labelBundle;
        private ResourceBundle descriptionBundle;
        private ResourceBundle messageBundle;
        private ResourceBundle errorBundle;

        private LanguageResource()
        {
                setLocale(Locale.getDefault());
        }

        public static synchronized LanguageResource getInstance()
        {
                if(instance == null)
                        instance = new LanguageResource();
                return instance;
        }

        public String getLabel(String key)
        {
                return labelBundle.getString(key);
        }

        public String getMessage(String key)
        {
                return messageBundle.getString(key);
        }

        public String getDescription(String key)
        {
                return descriptionBundle.getString(key);
        }

        public String getError(String key)
        {
                return errorBundle.getString(key);
        }

        public Locale getLocale()
        {
                return locale;
        }

        public void setLocale(Locale locale)
        {
                this.locale = locale;
                labelBundle = ResourceBundle.getBundle(ModelConstants.LABEL_BUNDLE, locale);
                descriptionBundle = ResourceBundle.getBundle(ModelConstants.DESCRIPTION_BUNDLE, locale);
                messageBundle = ResourceBundle.getBundle(ModelConstants.MESSAGE_BUNDLE, locale);
                errorBundle = ResourceBundle.getBundle(ModelConstants.ERROR_BUNDLE, locale);
        }

}
